package org.jinghouyu.caculator.engine;

import java.util.HashMap;
import java.util.Map;

import org.jinghouyu.caculator.engine.expression.FunctionExpression;

/**
 * 表达式上下文，暂时可以用来注册一些函数
 * @author liujingyu
 *
 */
public class ExpressionContext {

	private Map<String, Class<? extends FunctionExpression>> functions = new HashMap<>();
	
	public void addFunction(String name, Class<? extends FunctionExpression> functionClass) {
		functions.put(name.trim().toLowerCase(), functionClass);
	}
	
	public Class<? extends FunctionExpression> getFunctionExpression(String name) {
		return functions.get(name.trim().toLowerCase());
	}
	
	public void merge(ExpressionContext context) {
		functions.putAll(context.functions);
	}
}
